//
//  UPCalendarMonthCell.m
//  Uang Pasti
//
//  Created by 李永彬 on 2025/8/26.
//

#import "UPCalendarMonthCell.h"
#import <Masonry/Masonry.h>

@interface UPCalendarMonthCell ()

@property (nonatomic, strong) UILabel *monthLabel;

@end

@implementation UPCalendarMonthCell

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self.contentView addSubview:self.monthLabel];
        
        [self.monthLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.center.equalTo(self.contentView);
        }];
    }
    return self;
}

- (void)configureWithMonth:(NSInteger)month isSelected:(BOOL)isSelected {
    self.monthLabel.text = [NSString stringWithFormat:@"%ld", (long)month];
    self.monthLabel.textColor = isSelected ? [UIColor colorWithHexString:@"#000000"] : [UIColor colorWithHexString:@"#999999"];
    self.contentView.backgroundColor = isSelected ? [[UIColor colorWithHexString:@"#42714A"] colorWithAlphaComponent:0.1] : UIColor.clearColor;
    self.contentView.layer.masksToBounds = YES;
    self.contentView.layer.cornerRadius = 15.0;
}

- (UILabel *)monthLabel {
    if (!_monthLabel) {
        _monthLabel = [[UILabel alloc] init];
        _monthLabel.textAlignment = NSTextAlignmentCenter;
        _monthLabel.font = [UIFont systemFontOfSize:16];
    }
    return _monthLabel;
}

@end
